package com.tz.entity;

import javax.persistence.*;
import java.io.Serializable;

/**
 * Created by yejf on 2017/1/10.
 */
@Entity
@Table(name = "TBL_ACCOUNT")
public class Account implements Serializable {

    private Long id;  //PK

    private String no; //帐户号

    private String password; //密码

    private String realname; //真实姓名

    private double balance; //余额

    public Account() {
    }

    public Account(String no, String password, String realname, double balance) {
        this.no = no;
        this.password = password;
        this.realname = realname;
        this.balance = balance;
    }

    @Id
    @GeneratedValue
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Column(name = "no", unique = true, nullable = false, length = 18)
    public String getNo() {
        return no;
    }

    public void setNo(String no) {
        this.no = no;
    }

    @Column(name = "passwd")
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Column(name = "real_name")
    public String getRealname() {
        return realname;
    }

    public void setRealname(String realname) {
        this.realname = realname;
    }

    @Column
    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Account account = (Account) o;

        if (!id.equals(account.id)) return false;
        if (!no.equals(account.no)) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id.hashCode();
        result = 31 * result + no.hashCode();
        return result;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("Account{");
        sb.append("id=").append(id);
        sb.append(", no='").append(no).append('\'');
        sb.append(", password='").append(password).append('\'');
        sb.append(", realname='").append(realname).append('\'');
        sb.append(", balance=").append(balance);
        sb.append('}');
        return sb.toString();
    }
}
